<?php

namespace Xrfg\Api\Trading\Spot\Repositories;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class klineRepository
{
    /**
     * 创建K线数据库表.
     *
     * @param string $table
     */
    public function createTable($table)
    {
        Schema::connection('mysql_kline')->create($table, function (Blueprint $table) {
            $table->unsignedInteger('time_open')->comment('开盘时间');
            $table->unsignedInteger('time_close')->comment('收盘时间');
            $table->unsignedDecimal('price_open', 20, 8)->comment('开盘价');
            $table->unsignedDecimal('price_close', 20, 8)->comment('收盘价');
            $table->unsignedDecimal('price_high', 20, 8)->comment('最高价');
            $table->unsignedDecimal('price_low', 20, 8)->comment('最低价');
            $table->unsignedDecimal('trades_number', 20, 8)->comment('成交量');
            $table->unsignedDecimal('trades_total', 20, 8)->comment('成交额');
            $table->unsignedInteger('trades_count')->comment('成交数');

            $table->primary('time_open');
        });
    }
}
